package com.grz.dao.impl;

import com.grz.dao.IBrandDao;
import com.grz.domain.Brand;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public class BrandDaoImpl implements IBrandDao {

    private final JdbcTemplate jdbcTemplate;

    public BrandDaoImpl(JdbcTemplate jdbcTemplate) {

        this.jdbcTemplate = jdbcTemplate;
    }

    @Override
    public List<Brand> findAll() {
        List<Brand> brands = jdbcTemplate.query("select * from tb_brand", new BeanPropertyRowMapper<Brand>(Brand.class));
        return brands;
    }
}
